package com.example.linktop.activitylifecycle;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {

    public  static  final String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Log.d(TAG, getClass().getName());



        ImageView img = (ImageView) findViewById(R.id.img1);
        img.setImageResource(R.drawable.IMG_0005);

        if (savedInstanceState != null) {

            String name = savedInstanceState.getString("name");
        }

    }



    public  void  startNormal(View v) {

        Intent norIntent = new Intent(MainActivity.this, NornalActivity.class);
        startActivity(norIntent);


    }

    public void  startDialog(View v) {
        Intent diaIntent = new Intent(MainActivity.this, DialogActivity.class);
        startActivity(diaIntent);


    }


    /**
     * 测试回调顺序
     *
     * **/

    @Override
    protected void onStart() {
        super.onStart();
        Log.d(TAG, "onStart");



    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.d(TAG, "onResume");

    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.d(TAG, "onPause");

    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.d(TAG, "onStop");

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.d(TAG, "onDestroy");

        android.os.Process.killProcess(android.os.Process.myPid());
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.d(TAG, "onRestart");

    }


    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);

        String name = "lzp";
        outState.putString("name", name);

    }
}


